// 完全二叉树的节点

let root = [1, 2, 3, 4, 5, 6]

var countNodes = function (root) {
    if (!root) return 0

    let l = root, r = root
    let lh = 0, rh = 0
    while (l != null) {
        l = l.left
        lh++
    }

    while (r != null) {
        r = r.right
        rh++
    }

    if (lh === rh) {
        return lh + rh
    }

    countNodes(root.left)
    countNodes(root.right)
};